home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Technology Seed / ADC Seed CD - July 1999.toast / USB / Mac OS USB DDK v1.2 / Examples / UniversalModule / UniversalModule.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-04-15  |  3.5 KB  |  113 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        UniversalModule.h
  3.  
  4.     Contains:    Header file for universal module
  5.  
  6.     Version:    xxx put version here xxx
  7.  
  8.     Copyright:    © 1997-1998 by Apple Computer, Inc., all rights reserved.
  9.  
  10. */
  11. #ifndef __UniversalModuleH__
  12. #define __UniversalModuleH__
  13.  
  14. #include <Types.h>
  15. #include <Devices.h>
  16. #include <DriverServices.h>
  17. #include <USB.h>
  18.  
  19. // this is the prototype for all HIDModules that follow the UHID spec
  20. #include "UniversalHIDModule.h"
  21.  
  22. Boolean    immediateError(OSStatus err);
  23. void    UniversalModuleInitiateTransaction(USBPB *pb);
  24. void    UniversalModuleDelayCompletionProc(USBPB *pb);
  25. void     TransactionCompletionProc(USBPB *pb);
  26. void    DriverEntry(USBDeviceRef device, USBDeviceDescriptorPtr pDeviceDescriptor);
  27. void    InterfaceEntry(UInt32 interfaceNum, USBInterfaceDescriptorPtr pInterfaceDescriptor, USBDeviceDescriptorPtr pDeviceDescriptor, USBInterfaceRef interfaceRef);
  28. void    InterfaceExit(USBInterfaceRef interfaceRef, USBInterfaceDescriptorPtr pInterfaceDescriptor);
  29.  
  30. /*    Prototypes from UniversalModuleHeader.c    Tue, Mar 17, 1998 3:30:22 PM    */
  31. static     OSStatus    UniversalModuleInitialize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
  32. static     OSStatus    UniversalInterfaceInitialize(UInt32 interfaceNum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBInterfaceRef interfaceRef);
  33. static     OSStatus    UniversalModuleFinalize(USBDeviceRef theDeviceRef, USBDeviceDescriptorPtr pDesc);
  34.  
  35. /*    Prototypes from UniversalConfigParse.c    Tue, Mar 17, 1998 3:17:14 PM    */
  36. OSErr FindHIDInterfaceByInterfaceNumber(LogicalAddress pConfigDesc, UInt32 interfaceNumber, USBInterfaceDescriptorPtr * hInterfaceDesc);
  37. OSErr GetHIDDescriptors(USBConfigurationDescriptorPtr pConfigDesc, USBHIDDescriptorPtr * hHIDDesc);
  38.  
  39. /* Prototypes from UniversalHIDAPI.c */
  40. void NotifyRegisteredHIDUser(UInt8 hidReport[]);
  41. void DeferredNotifyRegisteredHIDUser(void * unused);
  42.  
  43. #define kUniversalRetryCount                10
  44. #define kDeferredHIDReportRingBufferSize    8
  45. #define kMaxHIDReportSize                    64    // 8 bytes for low speed, but 64 bytes for high speed
  46.  
  47. enum driverstages
  48. {
  49.     kUndefined = 0,
  50.     kGetHIDDesc,
  51.     kAllocHIDOwnedDescMem,
  52.     kGet1OwnedHIDDesc,
  53.     kConfigureInterface,
  54.     kFindInterruptPipe,
  55.     kReadInterruptPipe,
  56.     kDriverStagesMask =     0x0fff,
  57.     kReturnFromDriver =     0x1000,
  58.     kRetryTransaction =     0x2000,
  59.     kSyncTransaction =         0x4000,
  60.     kCompletionPending =     0x8000
  61. };
  62.  
  63. typedef union 
  64. {
  65.     USBHIDDescriptor    d;
  66.     UInt8                storage[256];
  67. } usbMaxHIDDescriptor;
  68.  
  69.  
  70.  
  71. typedef struct 
  72. {
  73.     UInt32                    type;        // 8 bits significant
  74.     UInt32                    length;        // 16 bits significant
  75.     UInt8 *                    descriptor;    // pointer to the descriptor
  76.     UInt32                    typeIndex;    // this is the ith item of this type
  77. } usbHIDDescriptorInfo;
  78.  
  79. typedef struct
  80. {
  81.     USBPB                             pb;            // this _must_ come first in the structure!
  82.     void (*handler)(USBPB             *pb);
  83.  
  84.     UInt32                             interfaceNum;
  85.     USBInterfaceRef                    interfaceRef;
  86.     USBPipeRef                        pipeRef;
  87.     
  88.     UInt32                            numPipes;
  89.     
  90.     USBDeviceDescriptor             deviceDescriptor;
  91.     USBInterfaceDescriptor            interfaceDescriptor;
  92.     usbMaxHIDDescriptor                hidDiscriptor;
  93.     usbHIDDescriptorInfo *            hidOwnedDiscriptors;
  94.     UInt32                            hidOwnedDescriptorsCount;
  95.     UInt32                            allocatedBufferSize;
  96.     
  97.     UInt32                            maxPacketSize;
  98.     UInt8                            hidReport[kMaxHIDReportSize];
  99.     
  100.     UInt8                            deferredHIDReports[kMaxHIDReportSize * kDeferredHIDReportRingBufferSize];
  101.     UInt32                            deferredHIDRing_Head;
  102.     UInt32                            deferredHIDRing_Tail;
  103.  
  104.     UHIDInterruptProcPtr             pClientInterruptRoutine;
  105.     UInt32                            clientRefCon;
  106.     
  107.     SInt32                             retryCount;
  108.     SInt32                            transDepth;
  109.     
  110. } usbUniversalPBStruct;
  111.  
  112. #endif //__UniversalModuleH__
  113.